package net.yla.smartbus.module.controller.web.ba.vehicletype;

import net.yla.smartbus.core.api.ApiResult;
import net.yla.smartbus.core.base.BaseController;
import net.yla.smartbus.module.ba.vehicletype.dto.BrandDto;
import net.yla.smartbus.module.ba.vehicletype.dto.BrandTree;
import net.yla.smartbus.module.ba.vehicletype.form.BrandForm;
import net.yla.smartbus.module.ba.vehicletype.serice.BrandService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 默苍离
 * @date 2021/6/24 9:43
 * <p>
 * ******************************************
 * @annotation:
 */
@RestController
@RequestMapping("/api/web/taxi/ba")
public class BrandController extends BaseController {

    private final BrandService service;

    public BrandController(BrandService service) {
        this.service = service;
    }


    /**
     * 获取所有品牌信息
     *
     * @return 品牌信息集合
     */
    @PostMapping("/brand/getList")
    public ApiResult getList() {
        List<BrandDto> list = service.getList();
        return success(list);
    }


    /**
     * 获取 品牌树
     *
     * @return
     */
    @PostMapping("/brand/getBrandTree")
    public ApiResult getBrandTree() {
        List<BrandTree> brandTree = service.getBrandTree();
        return success(brandTree);
    }


    /**
     * 添加品牌
     *
     * @return
     */
    @PostMapping("/brand/addBrand")
    public ApiResult addBrand(@RequestBody BrandForm form) {
        return success(service.insert(form));
    }


}
